﻿using Little.Soldier.SWIFT.Definition;
using System.Collections.Generic;

namespace Little.Soldier.SWIFT
{
    public class SwiftTagSequence : SwiftElement
    {
        private SwiftTagSequenceDefinition _Definition;

        internal override SwiftDefinitionElement Definition
        {
            get
            {
                return (SwiftDefinitionElement)this._Definition;
            }
        }

        internal SwiftTagSequence(SwiftElement parent, int index, SwiftTagSequenceDefinition definition)
          : base(parent, index)
        {
            this._Definition = definition;
        }

        internal SwiftTagSequence(SwiftElement parent, int index, bool createTags)
          : base(parent, index)
        {
            if (!createTags)
                return;
            foreach (SwiftDefinitionElement definitionElement in this.Definition.Elements)
                this.InitSwiftSwiftElement(definitionElement, (SwiftElement)this);
        }

        public override bool Equals(object obj)
        {
            if (this.GetType() != obj.GetType())
                return false;
            List<SwiftTag> list1 = this.ListTags((SwiftElement) this);
            List<SwiftTag> list2 = ((SwiftElement) obj).ListTags((SwiftElement) obj);
            if (list1.Count != list2.Count)
                return false;
            if (list1.Count == 0)
                return true;
            for (int index = 0; index < list1.Count; ++index)
            {
                if (!list1[index].Equals((object) list2[index]))
                    return false;
            }
            return true;
        }
  }
}
